<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends CommonController {
    public function index(){
    	$sql = "select t1.*,t2.nickname,t2.face,t3.cname from question t1 inner join user t2 on t1.uid=t2.id inner join category t3 on t1.cid=t3.id where t1.tip<>'0'";

    	$tips = M()->query($sql);
    	$this->assign('tips',$tips);


       $count =  M('question')->where("tip='0'")->count();

       $Page = new \Think\Page($count,6);  //一页显示多少个帖子

       $show = $Page->show();

       $this->assign('page',$show);


       // var_dump($Page->firstRow,$Page->listRows);


    	$sql = "select t1.*,t2.nickname,t2.face,t3.cname from question t1 inner join user t2 on t1.uid=t2.id inner join category t3 on t1.cid=t3.id where t1.tip='0' order by t1.create_time desc limit ".$Page->firstRow.",".$Page->listRows ;

    	$questions = M()->query($sql);
    	$this->assign('questions',$questions);
    	

    	$this->getTopUser();
    	$this->getTopView();
    	$this->getTopAnswer();
        $this->assign('title',"首页");
        $this->display();
    }
    public function qqreturn()
    {
      var_dump($_GET);
    }
}